package cn.ynrcb.personnelfile.admin.controller;

import cn.ynrcb.personnelfile.admin.entity.NoticeSendEntity;
import cn.ynrcb.personnelfile.admin.service.NoticeSendService;
import cn.ynrcb.personnelfile.common.utils.PageUtils;
import cn.ynrcb.personnelfile.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 通知发送表
 */
@RestController
@RequestMapping("admin/noticesend")
public class NoticeSendController {
    @Autowired
    private NoticeSendService noticeSendService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("admin:noticesend:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = noticeSendService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 导出
     */
    @RequestMapping("/export")
    @RequiresPermissions("admin:noticesend:export")
    public void export(@RequestParam Map<String, Object> params){
        List<NoticeSendEntity> list = noticeSendService.queryList(params);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("admin:noticesend:info")
    public R info(@PathVariable("id") Long id){
		NoticeSendEntity noticeSend = noticeSendService.getById(id);

        return R.ok().put("noticeSend", noticeSend);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:noticesend:save")
    public R save(@RequestBody NoticeSendEntity noticeSend){
		noticeSendService.save(noticeSend);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:noticesend:update")
    public R update(@RequestBody NoticeSendEntity noticeSend){
		noticeSendService.updateById(noticeSend);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:noticesend:delete")
    public R delete(@RequestBody Long[] ids){
		noticeSendService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
